import { BaseEntity, Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import { GuardEntity } from '../../guard/entities/guard.entity';
import { RoleType } from '../constants/role.constant';

@Entity('roles')
export class RoleEntity extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  uuid: string;

  @Column('varchar', { comment: '角色名' })
  name: string;

  @Column('varchar', { comment: '角色描述', nullable: true })
  description: string;

  @Column('enum', { enum: RoleType, comment: '角色类型', default: RoleType.system })
  type: RoleType;

  @CreateDateColumn({ type: 'timestamp', name: 'created_at', comment: '创建时间(typeorm自动生成)' })
  @Index()
  createdAt: Date;

  @Column('uuid', { array: true, name: 'guard_uuid_list', comment: '权限Uuid列表' })
  guardUuidList: string[];

  guardList: GuardEntity[];
}
